/*
 * This file is generated by jOOQ.
 */
package ru.ra_tech.garden_manager.database.schema.tables;


import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.Function5;
import org.jooq.Identity;
import org.jooq.Name;
import org.jooq.Record;
import org.jooq.Records;
import org.jooq.Row5;
import org.jooq.Schema;
import org.jooq.SelectField;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.UniqueKey;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

import ru.ra_tech.garden_manager.database.schema.Keys;
import ru.ra_tech.garden_manager.database.schema.Public;
import ru.ra_tech.garden_manager.database.schema.tables.records.GardensParticipantsRecord;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class GardensParticipants extends TableImpl<GardensParticipantsRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>public.gardens_participants</code>
     */
    public static final GardensParticipants GARDENS_PARTICIPANTS = new GardensParticipants();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<GardensParticipantsRecord> getRecordType() {
        return GardensParticipantsRecord.class;
    }

    /**
     * The column <code>public.gardens_participants.id</code>.
     */
    public final TableField<GardensParticipantsRecord, Long> ID = createField(DSL.name("id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "");

    /**
     * The column <code>public.gardens_participants.garden</code>.
     */
    public final TableField<GardensParticipantsRecord, Long> GARDEN = createField(DSL.name("garden"), SQLDataType.BIGINT.nullable(false), this, "");

    /**
     * The column <code>public.gardens_participants.participant</code>.
     */
    public final TableField<GardensParticipantsRecord, Long> PARTICIPANT = createField(DSL.name("participant"), SQLDataType.BIGINT.nullable(false), this, "");

    /**
     * The column <code>public.gardens_participants.role</code>.
     */
    public final TableField<GardensParticipantsRecord, Integer> ROLE = createField(DSL.name("role"), SQLDataType.INTEGER, this, "");

    /**
     * The column <code>public.gardens_participants.assignedAt</code>.
     */
    public final TableField<GardensParticipantsRecord, OffsetDateTime> ASSIGNEDAT = createField(DSL.name("assignedAt"), SQLDataType.TIMESTAMPWITHTIMEZONE(6).nullable(false).defaultValue(DSL.field(DSL.raw("now()"), SQLDataType.TIMESTAMPWITHTIMEZONE)), this, "");

    private GardensParticipants(Name alias, Table<GardensParticipantsRecord> aliased) {
        this(alias, aliased, null);
    }

    private GardensParticipants(Name alias, Table<GardensParticipantsRecord> aliased, Field<?>[] parameters) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
    }

    /**
     * Create an aliased <code>public.gardens_participants</code> table
     * reference
     */
    public GardensParticipants(String alias) {
        this(DSL.name(alias), GARDENS_PARTICIPANTS);
    }

    /**
     * Create an aliased <code>public.gardens_participants</code> table
     * reference
     */
    public GardensParticipants(Name alias) {
        this(alias, GARDENS_PARTICIPANTS);
    }

    /**
     * Create a <code>public.gardens_participants</code> table reference
     */
    public GardensParticipants() {
        this(DSL.name("gardens_participants"), null);
    }

    public <O extends Record> GardensParticipants(Table<O> child, ForeignKey<O, GardensParticipantsRecord> key) {
        super(child, key, GARDENS_PARTICIPANTS);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : Public.PUBLIC;
    }

    @Override
    public Identity<GardensParticipantsRecord, Long> getIdentity() {
        return (Identity<GardensParticipantsRecord, Long>) super.getIdentity();
    }

    @Override
    public UniqueKey<GardensParticipantsRecord> getPrimaryKey() {
        return Keys.GARDENS_PARTICIPANTS_PKEY;
    }

    @Override
    public List<UniqueKey<GardensParticipantsRecord>> getUniqueKeys() {
        return Arrays.asList(Keys.UNIQUE_PARTICIPANT);
    }

    @Override
    public GardensParticipants as(String alias) {
        return new GardensParticipants(DSL.name(alias), this);
    }

    @Override
    public GardensParticipants as(Name alias) {
        return new GardensParticipants(alias, this);
    }

    @Override
    public GardensParticipants as(Table<?> alias) {
        return new GardensParticipants(alias.getQualifiedName(), this);
    }

    /**
     * Rename this table
     */
    @Override
    public GardensParticipants rename(String name) {
        return new GardensParticipants(DSL.name(name), null);
    }

    /**
     * Rename this table
     */
    @Override
    public GardensParticipants rename(Name name) {
        return new GardensParticipants(name, null);
    }

    /**
     * Rename this table
     */
    @Override
    public GardensParticipants rename(Table<?> name) {
        return new GardensParticipants(name.getQualifiedName(), null);
    }

    // -------------------------------------------------------------------------
    // Row5 type methods
    // -------------------------------------------------------------------------

    @Override
    public Row5<Long, Long, Long, Integer, OffsetDateTime> fieldsRow() {
        return (Row5) super.fieldsRow();
    }

    /**
     * Convenience mapping calling {@link SelectField#convertFrom(Function)}.
     */
    public <U> SelectField<U> mapping(Function5<? super Long, ? super Long, ? super Long, ? super Integer, ? super OffsetDateTime, ? extends U> from) {
        return convertFrom(Records.mapping(from));
    }

    /**
     * Convenience mapping calling {@link SelectField#convertFrom(Class,
     * Function)}.
     */
    public <U> SelectField<U> mapping(Class<U> toType, Function5<? super Long, ? super Long, ? super Long, ? super Integer, ? super OffsetDateTime, ? extends U> from) {
        return convertFrom(toType, Records.mapping(from));
    }
}
